package org.example.niceoil.controller;

import org.example.niceoil.mapper.AllprocMapper;
import org.example.niceoil.mapper.CustomerMapper;
import org.example.niceoil.mapper.RecordMapper;
import org.example.niceoil.mapper.ViewRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/idu")
public class IDUController {
    private CustomerMapper CustomerMapper;
    private RecordMapper RecordMapper;
    private ViewRecordMapper ViewRecordMapper;
    private AllprocMapper AllprocMapper;
    @Autowired
    public IDUController(AllprocMapper AllprocMapper,RecordMapper RecordMapper,CustomerMapper CustomerMapper,ViewRecordMapper ViewRecordMapper){
        this.CustomerMapper=CustomerMapper;
        this.RecordMapper=RecordMapper;
        this.ViewRecordMapper=ViewRecordMapper;
        this.AllprocMapper=AllprocMapper;
    }
    @PostMapping("/Drecord")
    public String Drecord(@RequestBody Map<String, String> Ddata){
        String re="no";
        String de=Ddata.get("dedata");
        try{
            RecordMapper.deleteById(Integer.parseInt(de));
            re="yes";
        }catch (Exception e){
            return "no";
        }
        return re;
    }
}
